package com.moniteach.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import android.widget.EditText;

public class Encode {
	private static Encode instance;
	private String charset = "UTF-8";

	private Encode() {
	}

	public String encodeEditText(EditText et) {
		try {
			return URLEncoder.encode(et.getText().toString(), charset);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return null;
	}

	public String editText(EditText et) {
		return et.getText().toString();
	}

	public String encodeString(String str) {
		try {
			return URLEncoder.encode(str, charset);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return null;
	}

	public synchronized static Encode getInstance() {
		if (instance == null) {
			instance = new Encode();
		}
		return instance;
	}
}
